package org.xmonkey.notifier.model;

import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.dom.ASTNode;

/**
 * This interface describes what a notificator does.
 * It register clients, it visits projects and notifies clients
 * @author jacopom
 *
 */
public interface INotifier {
	
	/**
	 * Clients can use this method to register themselves to be notified
	 * ass soon as X-Monkey will visit a specific node
	 * @param project the project to monitor for AST visits
	 * @param nodeType the type of of the node the client is intereted in (ie: ASTNode.ARRAY_TYPE)
	 * @param subscriber the client registering for the notification
	 */
	public void registerNotificationRequestFor(IProject project, int nodeType, ISubscriber subscriber);
	
	/**
	 * Clients can instruct X-Monkey to visit a project, with this method
	 * @param project the project to be visited
	 */
	public void startVisitFor(IProject project);
	
	/**
	 * A client can register itself to be notified as soon as X-Monkey starts visiting a project
	 * @param project the project
	 * @param subscriber the subscriber that will be notified
	 */
	public void registerStartNotificationRequestFor(IProject project, ISubscriber subscriber);
	
	/**
	 * A client can register itself to be notified as soon as X-Monkey ends visiting a project
	 * @param project the project
	 * @param subscriber the subscriber that will be notified
	 */
	public void registerEndNotificationRequestFor(IProject project, ISubscriber subscriber);
	
	/**
	 * This method removes all kinds of subscriptions for a given client on a given project
	 * @param project the project
	 * @param subscriber the client that wants to be unsubscribed
	 */
	public void removeAllSubscriptions(IProject project, ISubscriber subscriber);
	
	/**
	 * This method removes end-of-visit subscriptions for a given client on a given project
	 * @param project the project
	 * @param subscriber the client that wants to be unsubscribed
	 */
	public void removeEndSubscriptions(IProject project, ISubscriber subscriber);
	
	/**
	 * This method removes start-of-visit subscription for a given client on a given project
	 * @param project the project
	 * @param subscriber the client that wants to be unsubscribed
	 */
	public void removeStartSubscriptions(IProject project, ISubscriber subscriber);
	
	/**
	 * This method is responsible for notifying subscribers about visits to ASTNodes
	 * @param project the visited project
	 * @param node th visited node
	 */
	public void notifyVisit(IProject project, ASTNode node);
	
	/**
	 * This method is responsible for notifying subscribers about starting visits
	 * @param project the visited project
	 */
	public void notifyStart(IProject project);
	
	/**
	 * This method is responsible for notifying subscribers about ending visits
	 * @param project the visited project
	 */
	public void notifyEnd(IProject project);

}
